﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="SouthernLand.Controls.SlideShow"
    CodeBehind="SlideShow.ascx.cs" %>
<%@ Import Namespace="System.IO" %>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td class="border-image-detail">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center">
                        <img border="0" width="574px" id="imageSlides" style="filter: revealTrans(duration=2,transition=5);
                            border: 0px solid red" title="Slide Show">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<script language="javascript">
            var imgArray = new Array;
            <%
              // khai bao stt lam bien toan cuc luon
              int stt = 0;
              string jscript = "";     
              DirectoryInfo d = new DirectoryInfo(Request.PhysicalApplicationPath + "UserUpload/SlideShow");
              foreach (FileInfo f in d.GetFiles())
              {
                  jscript += "imgArray[" + stt + "]='" + Globals.ApplicationPath +
                     "UserUpload/SlideShow/" + f.Name + "$$$;'";
                  jscript += "\n";
                  stt = stt + 1;
              }
              
              Response.Write(jscript);
            %>
            
            var currImg = parseInt(Math.random()* parseInt(<%=stt%>) );
            var ns=(navigator.appName.indexOf("Netscape")!=-1);
            var img=document.getElementById('imageSlides');
            doTransslide(currImg);
            
            function doTransslide()
            {
                if (currImg==imgArray.length) 
                    currImg=0;
                 
                var ua = navigator.userAgent;
                var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null)
                rv = parseFloat( RegExp.$1 );                       
                if(navigator.appName=="Microsoft Internet Explorer" && rv < 8)
                {
                    var part=imgArray[currImg].split("$$$");
                    var srcimage=part[0];
                    var url=part[1];
                    img.filters[0].apply();
                    document.images[img.id].src=srcimage;
                    document.images[img.id].alt=url;
                    document.getElementById(img.id).filters[0].transition = 12;
                    document.getElementById(img.id).filters[0].play();
                }
                else
                {
                    var ImageURL=imgArray[currImg].split("$$$").toString();
                    ImageURL=ImageURL.replace(";","").replace(",","");
                    document.images[img.id].src=ImageURL;
                }
                
                currImg = parseInt(Math.random()* parseInt(<%=stt %>) );
            }
            
            setInterval('doTransslide()',7000);
</script>
